package com.gitee.wsl.mathematics.vector.ext

import com.gitee.wsl.math.Math
import com.gitee.wsl.mathematics.vector.vec2.Vector2

fun<T:Number> Math.isCollinear(p1: Vector2<T, *>, p2: Vector2<T, *>, p3: Vector2<T, *>): Boolean {
    p1.run {
        val area2 = (p1.x * (p2.y - p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y)) // 2x triangle area
        //println("($p1x, $p1y), ($p2x, $p2y), ($p3x, $p3y) :: area=$area2")
        return area2.isApproxZero()
    }
}